package cn.com.yusys.yusp.admin.Utils;

import com.esms.MessageData;

import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * 工具类
 * 2021
 */
public class BlockQueueManager {
    private static BlockingQueue<List<MessageData>> notifyQueue = new LinkedBlockingQueue<List<MessageData>>();

    public static void offer(List<MessageData> data) throws InterruptedException {
        notifyQueue.offer(data, 2, TimeUnit.SECONDS);
    }

    public static List<MessageData> get() throws InterruptedException {
        return notifyQueue.poll(2, TimeUnit.SECONDS);
    }

    public static int getSize(){
        return notifyQueue.size();
    }

    public static BlockingQueue<List<MessageData>> getObject(){
        return notifyQueue;
    }
}
